﻿@{
    ViewBag.Title = "Register";
}
<link href="@Url.Content("~/UEditor/themes/default/css/umeditor.css")" type="text/css" rel="stylesheet">
<script type="text/javascript" src="@Url.Content("~/ueditor/ueditor.config.js")"></script>
<script type="text/javascript" src="@Url.Content("~/ueditor/ueditor.all.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/Validform/Validform_v5.3.1.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/common.js")"></script>


<h2>
    Add a topic</h2>
<form action="@Url.Action("savetopic")" id="addtopic" method="post" class="form-horizontal">
    

    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">标题</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="inputEmail3" datatype="*" placeholder="标题" />
        </div>
    </div>

    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">内容</label>
        <div class="col-sm-10">
            <script type="text/plain" id="editor" style="width:100%;height:200px;"></script>
        </div>
    </div>
        
    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">关键词</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="inputEmail3" placeholder="关键词" />
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
          <div class="checkbox">
            <label>
              <input type="checkbox" checked="checked" /> 是否允许TA人添加选项
            </label>
          </div>
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
          <button type="submit" class="btn btn-default">下一步</button>
        </div>
    </div>

</form>
<script type="text/javascript">
    var ue = UE.getEditor('editor', {
        focus: true,
        zIndex:9,
        contextMenu: [],
        emotionLocalization:true
    });

    $(function () {
        var addtopicform = $("#addtopic").Validform({
            showAllError: false,
            ajaxPost: true,
            btnSubmit: "button.btn",
            tipSweep: true,
            postonce: true,
            tiptype: function (msg, o, cssctl) {
                if (!o.obj.is("form") && o.type == 3) {
                    $.sp.Alert(msg, false);
                }
            },
            onSubmit: function (formdata) {
                $.sp.SimpleAjax("/topic/savetopic/", $.sp.toJsonString(formdata), function (d) {
                    $.sp.Alert("发布成功", true);
                    addtopicform.resetForm();
                });
            }
        });

        $("input.reset").click(function () {
            addtopicform.resetForm();
        });
    });
</script>
